struct Solution {}

fn main() {}

impl Solution {
    pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
        let mut idx_before = 0;
        let mut idx_after = 0;
        while idx_before != nums.len() {
            if idx_before == idx_after {
                idx_before += 1;
                continue;
            }
            if nums[idx_before] == nums[idx_after] {
                idx_before += 1;
                continue;
            }
            if nums[idx_before] != nums[idx_after] {
                idx_after += 1;
                nums[idx_after] = nums[idx_before];
                idx_before += 1;
            }
        }
        return (idx_after + 1) as i32;
    }
}
